home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE3 / SCRIBBLE / Examples / pdfclock < prev    next >
Text File  |  2002-07-05  |  1KB  |  78 lines

  1. -- pdfclock
  2. -- shows time when it was created.
  3.  
  4. RADIUS=200
  5. MARGIN=20
  6.  
  7. z = BEGIN (arg[1].."_pdf")
  8.  
  9. z:set_info( "Creator", "pdfclock.lua")
  10. z:set_info( "Author", "Thomas Merz")
  11. z:set_info( "Title", "PDF clock (Lua)")
  12.  
  13. z:begin_page( 2 * (RADIUS + MARGIN), 2 * (RADIUS + MARGIN))
  14.  
  15. z:translate( RADIUS + MARGIN, RADIUS + MARGIN)
  16. z:setcolor( "both", "rgb", 0, 0, 1, 0)
  17. z:save()
  18.  
  19. -- minute strokes
  20. z:setlinewidth( 2)
  21. for alpha = 0,360-6,6 do
  22.     z:rotate( 6)
  23.     z:moveto( RADIUS, 0)
  24.     z:lineto( RADIUS-MARGIN/3, 0)
  25.     z:stroke()
  26. end
  27.  
  28. z:restore()
  29. z:save()
  30.  
  31. -- 5 minute strokes
  32. z:setlinewidth( 3)
  33. for alpha = 0,360-30,30 do
  34.     z:rotate( 30)
  35.     z:moveto( RADIUS, 0)
  36.     z:lineto( RADIUS-MARGIN, 0)
  37.     z:stroke()
  38. end
  39.  
  40. _,_,hour,mins,sec=strfind(getenv("sys$time"),"(%d+):(%d+):(%d+)")
  41. -- draw hour hand
  42. z:save()
  43. z:rotate( -((mins/60) + hour - 3) * 30)
  44. z:moveto( -RADIUS/10, -RADIUS/20)
  45. z:lineto( RADIUS/2, 0)
  46. z:lineto( -RADIUS/10, RADIUS/20)
  47. z:closepath()
  48. z:fill()
  49. z:restore()
  50.  
  51. -- draw minute hand
  52. z:setcolor("both","rgb",0,1,0,0)
  53. z:save()
  54. z:rotate( -((sec/60) + mins - 15) * 6)
  55. z:moveto( -RADIUS/10, -RADIUS/20)
  56. z:lineto( RADIUS * 0.8, 0)
  57. z:lineto( -RADIUS/10, RADIUS/20)
  58. z:closepath()
  59. z:fill()
  60. z:restore()
  61.  
  62. -- draw second hand
  63. z:setcolor( "both", "rgb", 1, 0, 0, 0)
  64. z:setlinewidth( 2)
  65. z:save()
  66. z:rotate( -((sec - 15) * 6))
  67. z:moveto( -RADIUS/5, 0)
  68. z:lineto( RADIUS, 0)
  69. z:stroke()
  70. z:restore()
  71.  
  72. -- draw little circle at center
  73. z:circle( 0, 0, RADIUS/30)
  74. z:fill()
  75.  
  76. z:restore()
  77.  
  78. z:END()